package com.wyt.mq.activemq.topic;


import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;

public class Producer {


    public static void main(String[] args) throws JMSException{
        String ACTIVEMQ_URL = "tcp://localhost:61616";
        String Topic_NAME = "iac.ifoottraffic.flow_density_data.topic";
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ACTIVEMQ_URL);
        Connection connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createTopic(Topic_NAME);
        MessageProducer producer = session.createProducer(destination);
        TextMessage message = session.createTextMessage("待发送文本");
        producer.send(message);
    }

}
